home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Data Name to Pointer Question
- Date: 6 Mar 1996 20:45:03 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4hlpkfINN15r@keats.ugrad.cs.ubc.ca>
- References: <4hkhtb$epm@theopolis.orl.mmc.com>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <4hkhtb$epm@theopolis.orl.mmc.com>,
- Steve Woodcock <woodcock@escmail.orl.mmc.com> wrote:
- > Over in the program itself, "process one" is a data structure filled
- >with information.
- >
- > Is there a way for me to convert the string "process one" that I read
- >in from the data file to a pointer pointing to the actual structure
- >"process one"? Essentially, I want to turn the contents of this string
- >variable into the *name* of the variable I want to access.
-
- Not without incredible hackery that will render your program completely
- specific to a particular C implementation.
-
- By the way "process one" is not a legal C identifier name because it contains
- whitespace.
-
- What you _can_ do is store these structures in a list, and store a descriptive,
- unique name inside each structure. Then, do a lookup.
-
- K&R2 shows you, by example and discussion, how to write a simple module for
- creating a binary search tree. You could insert your structures into such a
- tree, where the descriptive label is used as the lookup key.
-
- Debugger programs can refer to variables by name, but they use debugging
- information to do this and are specific to particular environments/object
- formats. The method I suggest can be implemented using standard C.
-
-
-
-
-
-
-
- >Steve
- >
- >+=============================================================================+
- >| _ |
- >| Steven Woodcock _____C .._. |
- >| Senior Software Engineer, Gameware ____/ \___/ |
- >| Lockheed Martin Information Systems Group <____/\_---\_\ "Ferretman" |
- >| Phone: 719-597-5413 |
- >| E-mail: woodcock@escmail.orl.mmc.com (Work), swoodcoc@cris.com (Home) |
- >| Web: http://www.cris.com/~swoodcoc/ai.html (Games AI page) |
- >| http://www.cris.com/~swoodcoc/steve.html (Boring Steve Stuff) |
- >| Disclaimer: My opinions in NO way reflect the opinions of |
- >| the Lockheed Martin Information Systems Group |
- >+=============================================================================+
-
-
- --
-
-